<template>
  <div>
    <h1 class="title">修改订单信息</h1>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="订单状态">
        <el-select v-model="form.orderState" placeholder="请选择所属订单状态">
          <el-option label="待支付" :value="1 - 0"></el-option>
          <el-option label="以支付" :value="2 - 0"></el-option>
          <el-option label="已取消" :value="3 - 0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="订单退保">
        <el-select v-model="form.isWarranty" placeholder="请选择订单退保">
          <el-option label="取消退保" value="3"></el-option>
          <el-option label="退保申请中" value="1"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="下单时间" style="width: 300px">
        <el-date-picker
          type="date"
          placeholder="选择下单时间"
          v-model="form.orderTIme"
          style="width: 100%"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          id="time"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit()">确认修改</el-button>
        <el-button @click="cancel()">取消修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
  "insuresorders"
);
export default {
  data() {
    return {
      form: {
        orderState: "",
        isWarranty: "",
        orderTIme: "",
      },
    };
  },
  created() {
    this.getOrdersById(getInsureById);
  },
  watch: {
    orderUpdate(val) {
      console.log(val);
      this.form = this.orderUpdate;
    },
  },
  computed: {
    ...mapState(["insuresorders", "orderUpdate"]),
  },
  methods: {
    ...mapActions(["getOrdersById", "updateOrder"]),
    onSubmit() {
      this.updateOrder({ _id: this.$route.params._id, update: this.form });
    },
    cancel() {
      this.$router.push("/System/InsuresOrdersList");
    },
  },
};
</script>

<style lang="scss" scoped>
.title {
  font-size: 18px;
  font-weight: lighter;
  margin: 10px 0;
}
.el-input {
  width: 200px;
}
.el-form-item__content {
  width: 200px;
}
</style>